package com.asdf.application.commands;

import java.util.List;

import com.asdf.application.Constants;
import com.asdf.application.NetServiceSimulator;
import com.asdf.external.INetserviceSimulator;
import com.asdf.external.LogWriter;

/**
 * @author Artem Barger
 *	ICommandLine descendant, which handles disconnecting command from command line.
 */
public class DisconnectCommand implements ICommandLine
{

	/* (non-Javadoc)
	 * @see com.asdf.application.commands.ICommandLine#execute(com.asdf.external.INetserviceSimulator, java.util.List)
	 */
	@Override
	public void execute( INetserviceSimulator simulator, List<String> parameters)
	{
		if ( parameters.size( ) != 2)
		{
			LogWriter.getInstance( ).reportError( Constants.ILLEGAL_PARAMETERS_MSG);
			return;
		}
		simulator.endConnection( parameters.get( 1), 
								((NetServiceSimulator)simulator).getConnectionTime( parameters.get( 1)));
	}

}
